-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Савельев Григорий #192
base: master
Are you sure you want to change the base?
Савельев Григорий #192
Conversation
|
||
public static class ObjectExtensions | ||
{ | ||
public static string IntoString<T>(this T instance, Func<StringSerializer<T>, StringSerializer<T>> config) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
ObjectPrinting/StringSerializer.cs
Outdated
|
||
private int? lineLength; | ||
|
||
string ISerializer.Serialize(object instance, int nestingLevel) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я тут если что не имела в виду совсем удалять интерфейс, он в целом логично выглядел)
Но ладно, можно не править)
ObjectPrinting/StringSerializer.cs
Outdated
|
||
private string SerializeEnumerable(IEnumerable enumerable, int nestingLevel) | ||
{ | ||
const int customOffset = 4; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
ObjectPrinting/StringSerializer.cs
Outdated
if (enumerable is IDictionary dict) FillDictionaryBody(); | ||
else FillSequenceBody(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
ObjectPrinting/StringSerializer.cs
Outdated
void FillSequenceBody() | ||
{ | ||
foreach (var element in enumerable) | ||
{ | ||
var output = (this as ISerializer).Serialize(element, nestingLevel); | ||
stringBuilder.AppendLine($"{previousIndent}{elementOffset}{output.TrimEnd()},"); | ||
} | ||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
public interface ISerializer | ||
{ | ||
public string Serialize(object instance, int nestingLevel); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -0,0 +1,6 @@ | |||
namespace ObjectPrinting.Contracts; | |||
|
|||
public interface ISerializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предлагаю сделать ISerializer<T>, Serialize<T>
Думаю, что так будет выглядеть логичнее
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Блин, тут дженерики не отобразились в комменте сначала, сейчас поправила
} | ||
|
||
[Test] | ||
public void Serializer_MustBeAbleTo_IgnoreTypes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обычно вместо MustBeAble пишут просто Should)
namespace StringSerializer.Tests; | ||
|
||
[TestFixture] | ||
public class StringSerializerTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тесты написаны хорошо!)
Я бы еще добавила тестов на то, что у тебя называется финальными объектами
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что-то в итоге так и не увидела теста на финальные объекты
Может не очень понятно написала, но смысл такой: написать тест в который будет сериализовать int/double/DateTime...,
@@ -1,14 +1,9 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@elizShtol